﻿using System;
using System.Drawing;
using System.IO;
using System.Net;

namespace TextEditor
{
    

    public class ZYTextConst
    {
        public const string c_Align = "align";
        public const string c_BegSob = "([{\x00b7‘“〈《「『【〔〖（．［｛￡￥";
        public const string c_Body = "body";
        public const string c_Br = "br";
        public const string c_Cell = "cell";
        public const string c_Checked = "checked";
        public const string c_ClipboardDataFormat = "emrtextdocument2005";
        public const string c_CmdCopy = "copy";
        public const string c_CmdCut = "cut";
        public const string c_CmdDelete = "delete";
        public const string c_CmdPaste = "paste";
        public const string c_CmdRefresh = "refresh";
        public const string c_CmdSetBKColor = "setbkcolor";
        public const string c_CmdSetBold = "setbold";
        public const string c_CmdSetBorder = "setborder";
        public const string c_CmdSetColor = "setcolor";
        public const string c_CmdSetFont = "setfont";
        public const string c_CmdSetFontSize = "setfontsize";
        public const string c_CmdSetItalic = "setitalic";
        public const string c_CmdSetUnderLine = "setunderline";
        public const int c_CmToTwip = 0x237;
        public const string c_Col = "col";
        public const string c_ColCount = "colcount";
        public const int c_ComBoxSize = 0x10;
        public const string c_Count = "count";
        public const string c_Creator = "creator";
        public const string c_Creators = "creators";
        public const string c_DataSource = "datasource";
        public const string c_Deleted = "deleted";
        public const string c_Deleter = "deleter";
        public const string c_DisplayName = "displayname";
        public const string c_Div = "div";
        public const string c_DocSetting = "docsetting";
        public const string c_Element = "element";
        public const string c_Elements = "elements";
        public const string c_ZYTextDoc = "emrtextdoc";
        public const string c_Expanded = "expanded";
        public const int c_ExpendBoxSize = 8;
        public const string c_Field = "field";
        public const string c_FontBold = "fontbold";
        public const string c_FontItalic = "fontitalic";
        public const string c_FontName = "fontname";
        public const string c_FontSize = "fontsize";
        public const string c_FontUnderLine = "fontunderline";
        public const string c_ForeColor = "forecolor";
        public const string c_Format = "format";
        public const string c_Height = "height";
        public const string c_HideTitle = "hidetitle";
        public const string c_HR = "hr";
        public const string c_Href = "href";
        public const string c_ID = "id";
        public const string c_Img = "img";
        public const string c_Input = "input";
        public const string c_KB = "kb";
        public const string c_Key = "key";
        public const string c_KeyField = "keyfield";
        public const string c_KeyWord = "keyword";
        public const string c_Left = "left";
        public const string c_LineColor = "linecolor";
        public const string c_LineWidth = "linewidth";
        public const string c_Link = "link";
        public const string c_ListSource = "listsource";
        public const float c_MmToPixel = 2.835f;
        public const string c_Multiple = "multiple";
        public const string c_Name = "name";
        public const string c_NoContent = "nocontent";
        public const string c_NoSelect = "<未选择>";
        public const string c_Option = "option";
        public const string c_Options = "options";
        public const string c_Owner = "owner";
        public const string c_OwnerCol = "ownerCol";
        public const string c_OwnerRow = "ownerRow";
        public const string c_OwnerTable = "ownertable";
        public const string c_P = "p";
        public const string c_Readonly = "readonly";
        public const string c_Row = "row";
        public const string c_RowCount = "rowcount";
        public const string c_SaveInFile = "saveinfile";
        public const string c_SaveList = "savelist";
        public const string c_SaveMode = "savemode";
        public const string c_Script = "script";
        public const string c_Select = "select";
        public const string c_Selected = "selected";
        public const string c_SetLineSpacing = "setlinespacing";
        public const string c_SetValue = "setvalue";
        public const string c_Source = "source";
        public const string c_Span = "span";
        public const string c_Src = "src";
        public const int c_State_Checked = 0x400;
        public const int c_State_Normal = 0;
        public const string c_StructZY = "structemr";
        public const string c_Sub = "sub";
        public const string c_Sup = "sup";
        public const string c_Table = "table";
        public const string c_TailSob = "!),.:;?]}\x00a8\x00b7ˇˉ―‖’”…∶、。〃々〉》」』】〕〗！＂＇），．：；？］｀｜｝～￠\"'";
        public const string c_Text = "text";
        public const string c_Title = "title";
        public const string c_TitleLine = "titleline";
        public const string c_Top = "top";
        public const string c_Type = "type";
        public const string c_Unit = "unit";
        public const string c_Value = "value";
        public const string c_ValueSource = "valuesource";
        public const string c_Version = "version";
        public const string c_VMContinue = "continue";
        public const string c_VMerge = "vmerge";
        public const string c_VMStart = "restart";
        public const string c_Width = "width";
        public const string c_XMLFontName = "xmlfontname";
        public const string c_XMLText = "#text";
        public const string CollapseToolTip = "收缩文本块";
        public const string ERR_ImgFileNotFined = "未找到图片文件";
        public const string ExpendToolTip = "展开文本块";
      //  public static Color LockedForeColor = Color.DimGray;//color after locked
        public static Color LockedForeColor = SystemColors.WindowText;

        public static Image ImageFromURL(string strURL)
        {
            try
            {
                if (strURL != null)
                {
                    strURL = strURL.Trim();
                    if (!strURL.ToLower().StartsWith("http://"))
                    {
                        return Image.FromFile(strURL);
                    }
                    using (WebClient client = new WebClient())
                    {
                        Stream stream = client.OpenRead(strURL);
                        if (stream != null)
                        {
                            Image image = Image.FromStream(stream);
                            stream.Close();
                            return image;
                        }
                    }
                }
                return null;
            }
            catch
            {
                return null;
            }
        }
    }
}

